import { h } from "vue";
import { ElSelect, ElOption } from "element-plus";
import type { ConfigItem } from "./index.d";
const Select = (item: ConfigItem, data: any) => {
  return h(
    ElSelect,
    {
      placeholder: "请选择" + item.label,
      clearable: true,
      modelValue: data[item.prop],
      "onUpdate:modelValue": (value: any) => {
        data[item.prop] = value;
      },
      style: { width: "200px" } // 添加 width 样式
    },
    {
      // 渲染每个 option
      default: () =>
        item.options.map((option: any) =>
          h(ElOption, {
            key: option.value,
            label: option.label,
            value: option.value,
            disabled: option.disabled
          })
        )
    }
  );
};
export default Select;
